package com.jsgt.greekfire.ui.mine.coindetail.adapter

import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseViewHolder
import com.fhx.core.utils.DateFormatUtil
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.BillBean

/**
 * author fhx
 * create time 2020/4/24 15:11
 **/
class RechargeRecordAdapter : BaseAdapter<BillBean>() {

    inner class VH(itemView: View) : BaseViewHolder(itemView) {
        var record_content_tv: TextView? = null
        var record_time_tv: TextView? = null

        init {
            record_content_tv = itemView.findViewById(R.id.record_content_tv)
            record_time_tv = itemView.findViewById(R.id.record_time_tv)
        }

        fun bindData(bean: BillBean) {
            when (bean.assetEvent) {
                1 -> record_content_tv?.text =
                    Html.fromHtml("完成<font color= '#F0CF51'>${bean.assetAmt}</font> USDT充币")
                2 -> record_content_tv?.text =
                    Html.fromHtml("完成<font color= '#F0CF51'>${bean.assetAmt}</font> USDT提现")
            }

            record_time_tv?.text = DateFormatUtil.formatNew(bean.createTime, "MM月dd日 HH:mm")
        }
    }

    override fun provideViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.item_recharge_record, parent, false)
        return VH(view)
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        val viewHolder = holder as VH
        viewHolder.bindData(dataList()[position])
    }
}